-
Notifications
You must be signed in to change notification settings - Fork 957
Store dist manifest in JSON to improve load performance #4344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for working on this! Not sure whether this is intended as just sharing your experiment or whether you actually want to land this. I feel like we should explore #2626 (comment) a bit before we invest time in this. |
Especially since that reduced list of installed components might be more amenable to a smaller binary format like Postcard compared to the full manifest. |
I mostly wanted to see how much code would have to be changed to use the JSON format, seems like not that much. So I don't think it would be so bad to land as-is. Doing the other approach would likely require larger code changes, but it might be a better solution overall. I would have to first understand how do the manifests work to implement it though. |
The structure of the code makes it a bit challenging to change this. Essentially, the code first loads the full manifest, then it goes through all its However, while investigating this, I also noticed something interesting. In the "common case", where you just execute #4350 should fix this. |
I think that this change is no longer worth it now that #4350 has been merged. |
Wouldn't this still be worth it for the people who do specify components or targets in rust-toolchain.toml? Those are pretty common in my experience. |
It would definitely make the parsing faster for their use-cases. Not sure whether it is worth it to solve that with this specific approach, it seemed like it wasn't very popular with rustup maintainers. I'm of course willing to reopen and finish this if there's interset :) |
Maybe it would make sense to store a "mini manifest" only for targets that are installed? |
I guess it would be possible, yeah. And if the target file is not on disk, it would be considered to be missing. Note that I'm not sure how "mini" would the manifests be, it looked like the |
Currently, the
DIST_MANIFEST
(multirust-channel-manifest
) is being stored in TOML, which is not great for performance. The file has ~1 MiB on disk, and loading it takes ~24ms on my notebook. That's more than half the runtime of invokingrustc --version
throughrustup
.Since the manifest is generated and read only by
rustup
(AFAIK), I think that we could use a faster format to reduce this bottleneck. In this PR I chose to use JSON, for several reasons:serde_json
is well maintained and unlikely to be abandoned, and there are many other JSON (de)serialization alternatives.serde_json
can out of the box deal with the currentManifest
format. Since it uses#[serde(from...])
andskip_serializing
, this breaks other formats, such asbincode
,rmp_serde
(MsgPack) and Postcard. These would produce smaller files and even higher performance than JSON, but they would also require some changes to theManifest
structure.The manifest is parsed on more places (e.g.
make_component_unavailable
), but I only modified theDIST_CHANNEL
file, since that was the bottleneck that I saw.Context: #2626